home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 2
/
Atari Mega Archive CD - Volume 2.iso
/
minix
/
up1510b.tgz
/
up1510b
/
src
/
mm
/
alloc.c.D
next >
Wrap
Text File
|
1990-07-25
|
5KB
|
127 lines
*** /tmp/,RCSt1022393 Wed Jul 25 13:59:37 1990
--- alloc.c Mon Jul 23 10:56:03 1990
***************
*** 15,16 ****
--- 15,17 ----
* max_hole: returns the largest hole currently available
+ * mem_left: returns the sum of the sizes of all current holes
*/
***************
*** 17,21 ****
! #include "../h/const.h"
! #include "../h/type.h"
! #include "const.h"
--- 18,20 ----
! #include "mm.h"
***************
*** 34,35 ****
--- 33,37 ----
+ FORWARD void del_slot();
+ FORWARD void merge();
+
/*===========================================================================*
***************
*** 76,78 ****
*===========================================================================*/
! PUBLIC free_mem(base, clicks)
phys_clicks base; /* base address of block to free */
--- 78,80 ----
*===========================================================================*/
! PUBLIC void free_mem(base, clicks)
phys_clicks base; /* base address of block to free */
***************
*** 122,124 ****
*===========================================================================*/
! PRIVATE del_slot(prev_ptr, hp)
register struct hole *prev_ptr; /* pointer to hole entry just ahead of 'hp' */
--- 124,126 ----
*===========================================================================*/
! PRIVATE void del_slot(prev_ptr, hp)
register struct hole *prev_ptr; /* pointer to hole entry just ahead of 'hp' */
***************
*** 145,147 ****
*===========================================================================*/
! PRIVATE merge(hp)
register struct hole *hp; /* ptr to hole to merge with its successors */
--- 147,149 ----
*===========================================================================*/
! PRIVATE void merge(hp)
register struct hole *hp; /* ptr to hole to merge with its successors */
***************
*** 201,204 ****
*===========================================================================*/
! PUBLIC mem_init(clicks)
! phys_clicks clicks; /* amount of memory available */
{
--- 203,205 ----
*===========================================================================*/
! PUBLIC void mem_init()
{
***************
*** 207,213 ****
* a linked list of table entries that are not in use. Initially, the former
! * list has one entry, a single hole encompassing all of memory, and the second
! * list links together all the remaining table slots. As memory becomes more
! * fragmented in the course of time (i.e., the initial big hole breaks up into
! * many small holes), new table slots are needed to represent them. These
! * slots are taken from the list headed by 'free_slots'.
*/
--- 208,214 ----
* a linked list of table entries that are not in use. Initially, the former
! * list has one entry for each chunk of physical memory, and the second
! * list links together the remaining table slots. As memory becomes more
! * fragmented in the course of time (i.e., the initial big holes break up into
! * smaller holes), new table slots are needed to represent them. These slots
! * are taken from the list headed by 'free_slots'.
*/
***************
*** 215,224 ****
register struct hole *hp;
for (hp = &hole[0]; hp < &hole[NR_HOLES]; hp++) hp->h_next = hp + 1;
- hole[0].h_next = NIL_HOLE; /* only 1 big hole initially */
hole[NR_HOLES-1].h_next = NIL_HOLE;
! hole_head = &hole[0];
! free_slots = &hole[1];
! hole[0].h_base = 0;
! hole[0].h_len = clicks;
}
--- 216,247 ----
register struct hole *hp;
+ phys_clicks base; /* base address of chunk */
+ phys_clicks size; /* size of chunk */
+ /* Put all holes on the free list. */
for (hp = &hole[0]; hp < &hole[NR_HOLES]; hp++) hp->h_next = hp + 1;
hole[NR_HOLES-1].h_next = NIL_HOLE;
! hole_head = NIL_HOLE;
! free_slots = &hole[0];
!
! /* Allocate a hole for each chunk of physical memory. */
! while ( (size = get_mem(&base, FALSE)) != 0)
! free_mem(base, size);
! }
!
!
! /*===========================================================================*
! * mem_left *
! *===========================================================================*/
! PUBLIC phys_clicks mem_left()
! {
! /* Determine how much memory is left. This procedure is called just after
! * initialization to find the original amount.
! */
!
! register struct hole *hp;
! phys_clicks tot;
!
! for (hp = hole_head, tot = 0; hp != NIL_HOLE; hp = hp->h_next)
! tot += hp->h_len;
! return(tot);
}